// 用户的相关接口
import request from '@/utils/request.js'

// 登录
export const loginFun = ({ username, password }) => {
  return request({
    method: 'POST',
    url: '/api/login',
    data: {
      username,
      password,
    },
  })
}

// 注册
export const RegFun = ({ username, password, repassword }) => {
  return request({
    method: 'POST',
    url: '/api/reg',
    data: {
      username,
      password,
      repassword,
    },
  })
}

// 获取用户基本资料
export const getUserInfo = () => {
  return request({
    method: 'GET',
    url: '/my/userinfo',
  })
}

// 更新用户基本资料
export const updateUserInfo = (obj) => {
  return request({
    method: 'PUT',
    url: '/my/userinfo',
    data: obj,
  })
}

// 更新用户头像
export const updateUserAvatar = (avatar) => {
  return request({
    method: 'PATCH',
    url: '/my/update/avatar',
    data: { avatar },
  })
}

// 更新用户密码
export const updateUserPwd = (obj) => {
  return request({
    method: 'PATCH',
    url: '/my/updatepwd',
    data: obj,
  })
}
